package stringexercise;

public class StringBuilderDemo {
    public static void main(String[] args) {
        //创建一个StringBuilder对象
        StringBuilderDemo builder=new StringBuilderDemo();//创建一个空的builder
//        String s="abc";
        StringBuilder builder1=new StringBuilder("abc");
        String str="好好学习JAVA";
        StringBuilder builder2=new StringBuilder(str);

        builder2.append(",为了高薪工作");
        System.out.println(builder2);//好好学习JAVA，为了高薪工作

        builder2.replace(9,15,"为了改变世界");
        System.out.println(builder2);//好好学习JAVA,为了改变世界

        builder2.delete(0,8);
        System.out.println(builder2);//,为了改变世界

        builder2.insert(0,"活着");
        System.out.println(builder2);

        String s2=builder2.toString();//builder转化为String
        System.out.println(s2);



    }
}
